<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    function Parent(m){
        this.msg = m;
        this.show = function(){
            console.log(this.msg);
        }
    }
    Parent.prototype.init = function(){
        console.log("init")
    }
    Parent.prototype.say = function(){
        console.log("hi")
    }

    function Child(){}
    Child.prototype = new Parent("world");
    Child.prototype.say = function(){
        console.log("你好")
    }

    const p = new Parent("hello");
    console.log(p);
    p.show();
    p.init();
    p.say();
    
    const c1 = new Child();
    console.log(c1);
    c1.show();
    c1.init();
    c1.say();

    // 继承之后的原型链指向：
    // c1.__proto__指向了Child.prototype
    // Child.prototype指向了 Parent的实例
    // Parent的实例.__proto__指向Parent.prototype
    // Parent.prototype指向了Object.protptype

</script>
</html>